<div class="layuimini-container layuimini-page-anim" style="height: 100%">
    <!--富文本图表显示退款数据-->
    <div id="container" style="height: 100%;width: 80%;margin: 0"></div>

</div>

<!--图表-->
<script type="text/javascript">
    $(function () {
        /*柱状图*/
        $.ajax({
            url:"/refund",
            data:{},
            dataType:"json",
            success:function (data){
                var dom = document.getElementById("container");
                var myChart = echarts.init(dom);
                var app = {};
                var dataset1 = data.filter((p)=>{return p.name=='字节跳动'});
                var dataset2 = data.filter((p)=>{return p.name=='抖音'});
                var dataset3 = data.filter((p)=>{return p.name=='快手'});
                var dataset5 = data.filter((p)=>{return p.name=='腾讯'});
                var dataset6 = data.filter((p)=>{return p.name=='阿里巴巴'});
                var dataset7 = data.filter((p)=>{return p.name=='谷歌'});
                var dataset8 = data.filter((p)=>{return p.name=='小米'});
                var dataset4 = data.filter((p)=>{return p.name=='华为'});
                /*三个对象合并*/
                var innercount1 = dataset1.concat(dataset2);
                var innercount = innercount1.concat(dataset3);
                /*五个对象合并*/
                var outcount1 = dataset5.concat(dataset8);
                var outcount2 = outcount1.concat(dataset4);
                var outcount3 = outcount2.concat(dataset7);
                var outcount = outcount3.concat(dataset6);
                option = null;
                option = {
                    tooltip: {
                        trigger: 'item',
                        formatter: '{a} <br/>{b}: {c} ({d}%)'
                    },
                    legend: {
                        orient: 'vertical',
                        left: 10,
                        data: ['腾讯', '谷歌', '华为', '小米','阿里巴巴']
                    },
                    series: [
                        {
                            name: '合作商',
                            type: 'pie',
                            selectedMode: 'single',
                            radius: [5, '40%'],
                            label: {
                                position: 'inner'
                            },
                            labelLine: {
                                show: false
                            },
                            data:innercount
                        },
                        {
                            name: '合作商',
                            type: 'pie',
                            radius: ['60%', '75%'],
                            label: {
                                formatter: '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}  ',
                                backgroundColor: '#eee',
                                borderColor: '#faa',
                                borderWidth: 1,
                                borderRadius: 4,
                                rich: {
                                    a: {
                                        color: '#999',
                                        lineHeight: 22,
                                        align: 'center'
                                    },
                                    hr: {
                                        borderColor: '#aaa',
                                        width: '100%',
                                        borderWidth: 0.5,
                                        height: 0
                                    },
                                    b: {
                                        fontSize: 16,
                                        lineHeight: 33
                                    },
                                    per: {
                                        color: '#eee',
                                        backgroundColor: '#f34455',
                                        padding: [2, 4],
                                        borderRadius: 2
                                    }
                                }
                            },
                            data:outcount
                        }
                    ]
                };
                if (option && typeof option === "object") {
                    myChart.setOption(option, true);
                }
            }
        });
});

</script>
